package zheezes.protocol.impl.gd;


public class CtrlA1Frame extends MasterLinkFrame {
	private final byte[] pwd = new byte[3];
	
	public CtrlA1Frame(){
	}
	
	public CtrlA1Frame(byte[] pwd) {
		setPwd(pwd);
	}
	
	public int sizeOfData() {
		return pwd.length;
	}

	@Override
	public int getData(byte[] buf, int offset) {
		System.arraycopy(pwd, 0, buf, offset, pwd.length);
		return pwd.length;
	}

	@Override
	public int setData(byte[] buf, int offset, int max) {
		if (buf.length - offset >= 3) {
			System.arraycopy(buf, offset, pwd, 0, 3);
			return 0;
		}
		return -1;
	}
	
	public int setPwd(byte[] pwd) {
		if(pwd.length >= 3) {
			System.arraycopy(pwd, 0, this.pwd, 0, 3);
			return 0;
		}
		return -1;
	}
}
